#
# Copyright (C) 2011 nPulse Technologies, LLC
#
# January 17, 2011 Fork from nprobe 4.9.X to YAP 1.4.9
#

IFLAGS +=-I.
LDFLAGS+= -lz -lpcap  -lpthread
CFLAGS = $(USER_FLAGS) -Wall  $(IFLAGS) $(DEFINES) -O2 -march=native 

TARGET=yaprobe
DEPS = $(TARGET).h bucket.h config.h engine.h util.h 
OBJS = $(TARGET).o engine.o getopt.o util.o version.o

$(shell echo "$(CFLAGS)" > .tmp)

all: cflag-check $(TARGET)

cflag-check:
	@for o in $(OBJS) ;\
	do \
	if cmp .tmp $$o.cflags ;\
	then echo "No flag change detected" ;\
	else \
	cp .tmp $$o.cflags ;\
	rm -f $$o ;\
	fi >/dev/null 2>/dev/null ;\
	done

showflags:
	@echo CLFAGS : $(CFLAGS)
	@echo LDFLAGS: $(LDFLAGS)
	@echo IFLAGS : $(IFLAGS)

$(OBJS): Makefile

$(TARGET): $(OBJS) $(DEPS)
	@echo "      Linking: $@"
	@$(CC) $(OBJS) $(LDFLAGS) -o $@
	objcopy --strip-debug $@

clean:
	@rm -f $(OBJS) $(TARGET)

